From 06e6d224f7d564a34407eba21b51797da7f22628 Mon Sep 17 00:00:00 2001
From: Weijie Gao <weijie.gao@mediatek.com>
Date: Wed, 19 Jul 2023 17:16:11 +0800
Subject: [PATCH 06/29] reset: mediatek: check malloc return valaue before use

This patch add missing return value check for allocating the driver's
private data. -ENOMEM will be returned if malloc() fails.

Signed-off-by: Sam Shih <sam.shih@mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
 drivers/reset/reset-mediatek.c | 3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/reset/reset-mediatek.c
+++ b/drivers/reset/reset-mediatek.c
@@ -79,6 +79,9 @@ int mediatek_reset_bind(struct udevice *
 		return ret;
 
 	priv = malloc(sizeof(struct mediatek_reset_priv));
+	if (!priv)
+		return -ENOMEM;
+
 	priv->regofs = regofs;
 	priv->nr_resets = num_regs * 32;
 	dev_set_priv(rst_dev, priv);
